<?php 
  require_once('functions/config.php');
  
  $mysql_connect = mysql_connect( DB_CORE_ADDRESS, DB_CORE_USERNAME, DB_CORE_PASSWORD );
  $mysql_charset = mysql_query("SET NAMES utf8");
  $mysql_select_db = mysql_select_db( DB_CORE_DATABASE );
  $mysql_query = mysql_query("SELECT * FROM players WHERE id=1") or die('Błąd zapytania'); 
  
  if(mysql_num_rows($mysql_query) > 0) {
    while($r = mysql_fetch_assoc($mysql_query)) {
      $attack = $r['attack'];
      $defense = $r['defense'];
      $energy = $r['energy'];
      $exprience = $r['exprience'];
      $profession = $r['profession'];
      $name = $r['name'];
    }
  }
  mysql_close( $mysql_connect );
  
/* Czysty kod do użycia */
  //Obliczanie procentu z liczby
    function drawProgressBar ( $now, $need ) {
      $foo = ( $now / $need ) * 100;
      return $foo;
    }
  //Rozpoznawanie profesji Mag/Wojownik
    switch ( $profession ) {
      case 1:
        $profession = 'Mag';
        break;
      case 2:
        $profession = 'Wojownik';
        break;
      default:
        $profession = 'Brak';
    }
/* Koniec czystego kodu */      
  echo 'Doświadczenie: '.$exprience.'/100<div id="exprience"><div class="gained" style="width: '.drawProgressBar( $exprience, 100 ).'%; "></div></div>';
  echo 'Energia: '.$energy.'/100<div id="energy"><div class="gained" style="width: '.$energy.'% "></div></div>';
  echo 'Profesja: '.$profession;
  echo '<br />Atak: '.$attack;
  echo '<br />Obrona: '.$defense;
  echo '<br />Name: '.$name;
?>
